/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.yournamehere.client;

import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.RootPanel;

/**
 * Main entry point.
 *
 * @author Cristian
 */
public class MainEntryPoint implements EntryPoint {

	private final GWTServiceAsync greetingService = GWT.create(GWTService.class);

	/**
	 * This is the entry point method.
	 */
	public void onModuleLoad() {
		final Button target= new Button("Ver Datos");
		final Label label=new Label("vacio");
		RootPanel.get().add(target);
		RootPanel.get().add(label);

		class MyHandler implements ClickHandler{

			@Override
			public void onClick(ClickEvent event) {
				// TODO Auto-generated method stub
				ServerMsg();
			}

			private void ServerMsg() {
				// TODO Auto-generated method stub
				greetingService.myMethod("Cristian",new AsyncCallback<String>() {

					@Override
					public void onFailure(Throwable caught) {
						// TODO Auto-generated method stub
						label.setText("failure");
					}

					@Override
					public void onSuccess(String result) {
						// TODO Auto-generated method stub
						label.setText(result);
					}

				});
			}

		}
		MyHandler handler = new MyHandler();
		target.addClickHandler(handler);


	}
}